package com.learning.datastruct.collection.queue;

import com.learning.datastruct.collection.list.MyLinkedList;
import com.learning.datastruct.collection.list.MyList;


/**
 * 队列
 * @author ZLH
 */
public class MyDeque<E> {
    private MyList<E> list = new MyLinkedList<>();

    public int size()  {
        return list.size();
    }

    public boolean isEmpty() {
        return list.isEmpty();
    }

    public void clear() {
        list.clear();
    }

    public void addLast(E element) {
        list.add(element);
    }

    public E pollFirst() {
        return list.remove(0);
    }

    public void addFirst(E element) {
        list.add(0, element);
    }

    public E pollLast() {
        return list.remove(list.size() - 1);
    }

    public E peekFirst() {
        return list.get(0);
    }

    public E peekLast() {
        return list.get(list.size() - 1);
    }
}
